home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 21 code / MPW Tips - Faster Launch / Quit < prev    next >
Encoding:
Text File  |  1995-01-16  |  1.8 KB  |  79 lines  |  [TEXT/MPS ]

  1. # Quit and save state for fast startup
  2.  
  3. # We need to set Exit to 0 so that errors won't
  4. # cause Quit or Startup to bomb, but we also want
  5. # to maintain the user's setting of the Exit
  6. # variable. Save and restore it.
  7. Set SaveExit {Exit}
  8. Export SaveExit
  9. Set Exit 0
  10.  
  11. # State saving is turned off by creating a file
  12. # named DontSaveState in the MPW folder.
  13. If "`Exists "{ShellDirectory}"DontSaveState`"
  14.     Delete -i "{ShellDirectory}"DontSaveState ∂
  15.         "{ShellDirectory}"MPW.SuspendState ∂
  16.         ≥ Dev:Null
  17.         
  18. Else
  19.  
  20.     # Write the state to a temporary file.
  21.     Begin
  22.  
  23.         # Tell the restoration not to bomb.
  24.         Echo Set Exit 0
  25.  
  26.         # Save the custom menus.
  27.         AddMenu
  28.  
  29.         # Save the current directory.
  30.         Echo Directory "`Directory`"
  31.         
  32.         # Save the open windows.
  33.         Echo For window In "`Windows`"
  34.         Echo '    Open "{window}" || Set Status 0'
  35.         Echo 'End ≥ Dev:Null'
  36.     
  37.         # Save the aliases.
  38.         Alias
  39.  
  40.         # Save the variables.
  41.         Set
  42.  
  43.         # Save the exports. This runs much faster 
  44.         # with all the exports on one line, so we
  45.         # use -s to get all the names at once.
  46.         Echo Export "`Export -s`"
  47.                 
  48.         # Save the key assignments.
  49.         SetKey
  50.         # Save lines that will execute the UserMount
  51.         # script if any. The script doesn't have to
  52.         # exist, and it's harmless to throw it away
  53.         # between saving and restoring state.
  54.         If "`Exists "{ShellDirectory}"UserMount`"
  55.             Echo Execute ∂
  56.                 "{ShellDirectory}"UserMount ∂
  57.                  "≥ Dev:Null"
  58.         End
  59.  
  60.         # Save the mounted Projector databases and
  61.         # their checkout directories.
  62.         MountProject
  63.         CheckOutDir -r
  64.  
  65.         # After the rest of the state is restored
  66.         # with Exit set to 0 to prevent bombing,
  67.         # save lines to restore the user's setting
  68.         # of Exit.
  69.         Echo Set Exit '{SaveExit}'
  70.  
  71.     End > "{ShellDirectory}"MPW.SuspendState ∂
  72.          ≥ Dev:Null
  73.  
  74. End
  75.  
  76. # Sometimes anomalies prevent the Worksheet from
  77. # auto-saving at Quit time; make sure it does.
  78. Save "{Worksheet}"
  79.